﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EssentialTools.Models;

namespace EssentialTools.Controllers
{
    public class HomeController : Controller
    {
        private readonly ShoppingCart _shoppingCart;

        public HomeController(ShoppingCart shoppingCart)
        {
            _shoppingCart = shoppingCart;
        }
        //模拟数据
        private Product[] products =
        {
            new Product {Name = "帆船", Category = "水上运动", Price = 275m},
            new Product {Name = "救生衣", Category = "水上运动", Price = 45m},
            new Product {Name = "足球", Category = "足球运动", Price = 275m},
            new Product {Name = "角旗", Category = "足球运动", Price = 175m},
            new Product {Name = "篮球", Category = "篮球运动", Price = 25m},
            new Product {Name = "篮球筐", Category = "篮球运动", Price = 45m},
            new Product {Name = "篮球机", Category = "篮球运动", Price = 85m},
        };
        // GET: Home
        public ActionResult Index()
        {
            _shoppingCart.Products = products;
            var totalValue = _shoppingCart.CalculateProductTotal();
            return View(totalValue);
        }
    }
}